import 'package:guochaoapp/model/cart_settle_entity.dart';
import 'package:guochaoapp/model/order_detail_entity.dart';

orderDetailEntityFromJson(OrderDetailEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new OrderDetailData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> orderDetailEntityToJson(OrderDetailEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

orderDetailDataFromJson(OrderDetailData data, Map<String, dynamic> json) {
	if (json['mallOrderNo'] != null) {
		data.mallOrderNo = json['mallOrderNo'].toString();
	}
	if (json['mallOrderStatus'] != null) {
		data.mallOrderStatus = json['mallOrderStatus'].toString();
	}
	if (json['receiverName'] != null) {
		data.receiverName = json['receiverName'].toString();
	}
	if (json['receiverPhone'] != null) {
		data.receiverPhone = json['receiverPhone'].toString();
	}
	if (json['receiverAddr'] != null) {
		data.receiverAddr = json['receiverAddr'].toString();
	}
	if (json['createAt'] != null) {
		data.createAt = json['createAt'].toString();
	}
	if (json['priceTotal'] != null) {
		data.priceTotal = json['priceTotal'] is String
				? double.tryParse(json['priceTotal'])
				: json['priceTotal'].toDouble();
	}
	if (json['freightTotal'] != null) {
		data.freightTotal = json['freightTotal'] is String
				? int.tryParse(json['freightTotal'])
				: json['freightTotal'].toDouble();
	}
	if (json['balanceDeductionTotal'] != null) {
		data.balanceDeductionTotal = json['balanceDeductionTotal'] is String
				? int.tryParse(json['balanceDeductionTotal'])
				: json['balanceDeductionTotal'].toDouble();
	}
	if (json['paymentPriceTotal'] != null) {
		data.paymentPriceTotal = json['paymentPriceTotal'] is String
				? double.tryParse(json['paymentPriceTotal'])
				: json['paymentPriceTotal'].toDouble();
	}
	if (json['weightTotal'] != null) {
		data.weightTotal = json['weightTotal'] is String
				? double.tryParse(json['weightTotal'])
				: json['weightTotal'].toDouble();
	}
	if (json['canCancel'] != null) {
		data.canCancel = json['canCancel'];
	}
	if (json['itemList'] != null) {
		data.itemList = new List<CartSettleDataItemList>();
		(json['itemList'] as List).forEach((v) {
			data.itemList.add(new CartSettleDataItemList().fromJson(v));
		});
	}
	if (json['receiptCardDTO'] != null) {
		data.receiptCardDTO = new OrderDetailDataReceiptCardDTO().fromJson(json['receiptCardDTO']);
	}
	if (json['expireHours'] != null) {
		data.expireHours = json['expireHours'];
	}
	if (json['canInvoice'] != null) {
		data.canInvoice = json['canInvoice'];
	}
	if (json['hasInvoiced'] != null) {
		data.hasInvoiced = json['hasInvoiced'];
	}
	if (json['canReturn'] != null) {
		data.canReturn = json['canReturn'];
	}
	if (json['hasReturn'] != null) {
		data.hasReturn = json['hasReturn'];
	}
	if (json['returnPriceTotal'] != null) {
		data.returnPriceTotal = json['returnPriceTotal'] is String
				? double.tryParse(json['returnPriceTotal'])
				: json['returnPriceTotal'].toDouble();
	}
	if (json['returnItemList'] != null) {
		data.returnItemList = new List<OrderDetailDataReturnItemList>();
		(json['returnItemList'] as List).forEach((v) {
			data.returnItemList.add(new OrderDetailDataReturnItemList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> orderDetailDataToJson(OrderDetailData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['mallOrderNo'] = entity.mallOrderNo;
	data['mallOrderStatus'] = entity.mallOrderStatus;
	data['receiverName'] = entity.receiverName;
	data['receiverPhone'] = entity.receiverPhone;
	data['receiverAddr'] = entity.receiverAddr;
	data['createAt'] = entity.createAt;
	data['priceTotal'] = entity.priceTotal;
	data['freightTotal'] = entity.freightTotal;
	data['balanceDeductionTotal'] = entity.balanceDeductionTotal;
	data['paymentPriceTotal'] = entity.paymentPriceTotal;
	data['weightTotal'] = entity.weightTotal;
	data['canCancel'] = entity.canCancel;
	if (entity.itemList != null) {
		data['itemList'] =  entity.itemList.map((v) => v.toJson()).toList();
	}
	if (entity.receiptCardDTO != null) {
		data['receiptCardDTO'] = entity.receiptCardDTO.toJson();
	}
	data['expireHours'] = entity.expireHours;
	data['canInvoice'] = entity.canInvoice;
	data['hasInvoiced'] = entity.hasInvoiced;
	data['canReturn'] = entity.canReturn;
	data['hasReturn'] = entity.hasReturn;
	data['returnPriceTotal'] = entity.returnPriceTotal;
	if (entity.returnItemList != null) {
		data['returnItemList'] =  entity.returnItemList.map((v) => v.toJson()).toList();
	}
	return data;
}

orderDetailDataReceiptCardDTOFromJson(OrderDetailDataReceiptCardDTO data, Map<String, dynamic> json) {
	if (json['companyName'] != null) {
		data.companyName = json['companyName'].toString();
	}
	if (json['bankName'] != null) {
		data.bankName = json['bankName'].toString();
	}
	if (json['branchName'] != null) {
		data.branchName = json['branchName'].toString();
	}
	if (json['cardNo'] != null) {
		data.cardNo = json['cardNo'].toString();
	}
	if (json['countDown'] != null) {
		data.countDown = json['countDown'];
	}
	if (json['createStamp'] != null) {
		data.createStamp = json['createStamp'] is String
				? int.tryParse(json['createStamp'])
				: json['createStamp'].toInt();
	}
	if (json['endStamp'] != null) {
		data.endStamp = json['endStamp'] is String
				? int.tryParse(json['endStamp'])
				: json['endStamp'].toInt();
	}
	return data;
}

Map<String, dynamic> orderDetailDataReceiptCardDTOToJson(OrderDetailDataReceiptCardDTO entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['companyName'] = entity.companyName;
	data['bankName'] = entity.bankName;
	data['branchName'] = entity.branchName;
	data['cardNo'] = entity.cardNo;
	data['countDown'] = entity.countDown;
	data['createStamp'] = entity.createStamp;
	data['endStamp'] = entity.endStamp;
	return data;
}

orderDetailDataReturnItemListFromJson(OrderDetailDataReturnItemList data, Map<String, dynamic> json) {
	if (json['skuId'] != null) {
		data.skuId = json['skuId'] is String
				? int.tryParse(json['skuId'])
				: json['skuId'].toInt();
	}
	if (json['brandId'] != null) {
		data.brandId = json['brandId'] is String
				? int.tryParse(json['brandId'])
				: json['brandId'].toInt();
	}
	if (json['brandName'] != null) {
		data.brandName = json['brandName'].toString();
	}
	if (json['spuName'] != null) {
		data.spuName = json['spuName'].toString();
	}
	if (json['skuSpec'] != null) {
		data.skuSpec = json['skuSpec'].toString();
	}
	if (json['weight'] != null) {
		data.weight = json['weight'] is String
				? double.tryParse(json['weight'])
				: json['weight'].toDouble();
	}
	if (json['num'] != null) {
		data.num = json['num'] is String
				? int.tryParse(json['num'])
				: json['num'].toInt();
	}
	if (json['stock'] != null) {
		data.stock = json['stock'] is String
				? int.tryParse(json['stock'])
				: json['stock'].toInt();
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? double.tryParse(json['price'])
				: json['price'].toDouble();
	}
	if (json['buyLimit'] != null) {
		data.buyLimit = json['buyLimit'];
	}
	if (json['updateAt'] != null) {
		data.updateAt = json['updateAt'];
	}
	if (json['mallFee'] != null) {
		data.mallFee = json['mallFee'] is String
				? double.tryParse(json['mallFee'])
				: json['mallFee'].toDouble();
	}
	if (json['repoFee'] != null) {
		data.repoFee = json['repoFee'] is String
				? double.tryParse(json['repoFee'])
				: json['repoFee'].toDouble();
	}
	if (json['returnFee'] != null) {
		data.returnFee = json['returnFee'] is String
				? double.tryParse(json['returnFee'])
				: json['returnFee'].toDouble();
	}
	return data;
}

Map<String, dynamic> orderDetailDataReturnItemListToJson(OrderDetailDataReturnItemList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['skuId'] = entity.skuId;
	data['brandId'] = entity.brandId;
	data['brandName'] = entity.brandName;
	data['spuName'] = entity.spuName;
	data['skuSpec'] = entity.skuSpec;
	data['weight'] = entity.weight;
	data['num'] = entity.num;
	data['stock'] = entity.stock;
	data['price'] = entity.price;
	data['buyLimit'] = entity.buyLimit;
	data['updateAt'] = entity.updateAt;
	data['mallFee'] = entity.mallFee;
	data['repoFee'] = entity.repoFee;
	data['returnFee'] = entity.returnFee;
	return data;
}